import axios from 'axios';
import {BASE_URL} from "@/common/const";
const service = axios.create({
  baseURL: BASE_URL, // url = base url + request url
  timeout: 5000, // request timeout
});

service.interceptors.request.use(
    config => {
      return config;
    },
    error => {
      console.log('[request拦截]接口报错' + error); // for debug
      return Promise.reject(error);
    },
);

service.interceptors.response.use(
    response => {
      // console.log('[response拦截]接口数据:', response);
      return response.data;
    },
    error => {
      console.log('[response拦截]接口报错' + error);
      return Promise.reject(error);
    },
);

export default service;
